package com.content.view.Component.Loader
{
	import com.content.model.LoadedAssets.SkinProxy;
	import com.library.core.IDisposable;
	import com.library.core.UIObject;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.DropShadowFilter;
	
	import gs.TweenLite;
	
	public class BufferRing extends UIObject implements IDisposable
	{
		private var _ring:Sprite;
		
		public function BufferRing()
		{
			super();
			_ring = new SkinProxy.ICO_MP_BufferRing() as Sprite;
			setFilter();
			addChild(_ring);
			this.alpha = 0;
			this.visible = false;
		}
		
		// Method
		public function Dispose():void{
			removeEventListener(Event.ENTER_FRAME, OnEnterFrame);
		}
		public function fadeOut():void{
			TweenLite.to( this, 0.5, { autoAlpha: 0, delay: 0} );
		}
		
		public function fadeIn(duration:Number = 0.5, delay:Number=0):void{
			TweenLite.to( this, duration, { autoAlpha: 1, delay: delay, onComplete:OnFadedOut} );
			addEventListener(Event.ENTER_FRAME, OnEnterFrame);
		}
		
		// Function
		private function setFilter():void{
			var color:uint = 0;
			var angle:Number = 45;
			var alpha:Number = 0.8;
			var blurX:Number = 4;
			var blurY:Number = 4;
			var distance:Number = 2;
			var strength:Number = 0.65;
			var inner:Boolean = false;
			var knockout:Boolean = false;
			var quality:uint = BitmapFilterQuality.HIGH;
			var filter:DropShadowFilter = new DropShadowFilter(distance, angle, color, alpha, blurX, blurY, strength, quality, inner, knockout);
			var filterArr:Array = new Array();
			filterArr.push(filter);
			_ring.filters = filterArr;
		}
		
		// Event
		private function OnEnterFrame(evt:Event):void{
			_ring.rotation = (_ring.rotation + 15);
		}
		private function OnFadedOut(evt:Event):void{
			removeEventListener(Event.ENTER_FRAME, OnEnterFrame);
		}
	}
}